function currying(fn, newArgs = []) {
  let length = fn.length
  return function (...args) {
    args = [...args, ...newArgs]
    if (length == args.length) {
      return fn.apply(this, args)
    } else {
      // 收集
      return currying(fn, args)
    }
  }
}

// 用法如下：
const add = (a, b, c) => a + b + c;
const a = currying(add);
console.log(a(1, 2, 3))
console.log(a(1)(2)(3))

